package uk.gov.swmprobation.cplitebase;

import uk.gov.swmprobation.cplitebase.R;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class About extends MyActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about);
		
		actionBar.setHomeButtonEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(false);
		
        TextView about = (TextView) findViewById(R.id.about_info);
        about.setMovementMethod(LinkMovementMethod.getInstance());
        
        TextView licence = (TextView) findViewById(R.id.map_info);
        licence.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.licence_link)));
				startActivity(browserIntent);				
			}});
        
		TextView version = (TextView) findViewById(R.id.version);
		if (MyApplication.versionName != null){
	        version.setText("Version: " + MyApplication.versionName);
		} else {
	        version.setText("Version data not found");
		}  
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.about, menu);
		return true;
	}
    
    public void licence(View view){
		Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.licence_link)));
		startActivity(browserIntent);
	}

}
